String.prototype.format = function(fmt) {
	if (!fmt || fmt === {}) {
		return this;
	}
	let string = this;
	for (const key in fmt) {
		string = string.replace(new RegExp("\\{" + key + "\\}", "g"), fmt[key])
	}
	return string;
};
String.prototype.toJSON = function() {
	try {
		return JSON.parse(this);
	} catch (e) {
		console.error("string is must be a json string")
		return {};
	}
};
import pinyin from './convert-pinyin.js'
String.prototype.toPinYin = function() {
	return pinyin.getFullChars(this);
};
Array.prototype.conversion = function (fn) {
	let newArr = [];
	for (let i = 0; i < this.length; i++) {
		let temp = fn(this[i]);
		if(temp) newArr.push(temp);
	}
	return newArr;
}
export default {
	init() {
		console.log("*** string installed ***")
	}
}
